<!DOCTYPE html>
<!--
  ~ Copyright (c) 2018.
  ~ This file was written by fancyears·milos·malvis @connor. Any question/bug you can post to 1243093366@qq.com.
  ~ ALL RIGHTS RESERVED.
  -->

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<body>
<meta charset=utf-8/>
<form class="form-horizontal" id="form" role="form" method="post" th:action="${action}">
    <fieldset>
        <input id="pPertainToProjectPuid" name="pPertainToProjectPuid" type="hidden"
               th:value="${entity.pPertainToProjectPuid}"/>
        <input id="puid" name="puid" type="hidden" th:value="${puid}"/>
        <div id="legend" class="">
            <legend class="">更新超级物料信息</legend>
        </div>

        <div class="form-group col-lg-10">
            <label for="pMaterielCode">物料(号码)</label>
            <input class="form-control" id="pMaterielCode" name="pMaterielCode" type="text"
                   th:value="${entity.pMaterielCode}"/>
        </div>
        <div class="form-group col-lg-10">
            <label for="pMaterielDesc">物料描述(中文)</label>
            <input class="form-control" id="pMaterielDesc" name="pMaterielDesc" type="text"
                   th:value="${entity.pMaterielDesc}"/>
        </div>
        <div class="form-group col-lg-10">
            <label for="pMaterielWerk">工厂</label>
            <input class="form-control" id="pMaterielWerk" name="pMaterielWerk" type="text"
                   th:value="${entity.pMaterielWerk}"/>
        </div>
        <div class="form-group col-lg-10">
            <label for="pMaterielType">物料类型</label>
            <input class="form-control" id="pMaterielType" name="pMaterielType" type="text"
                   th:value="${entity.pMaterielType}" disabled="disabled"
            />
        </div>
    </fieldset>
</form>
<script th:inline="javascript">
    <![CDATA[
    $(function () {
        $('#form').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                pCodeOfColorfulModel: {
                    message: '车型颜色代码验证失败',
                    validators: {
                        notEmpty: {
                            message: '车型颜色代码不能为空'
                        }
                    }
                }
            }
        });
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            // var bootstrapValidator = $("#form", window.top.document).data('bootstrapValidator');
            // bootstrapValidator.validate();
            // if (bootstrapValidator.isValid()) {
            var url = $("#form", window.top.document).attr('action');
            var data = {};
            var _d = $("#form").serializeArray();
            for (var p in _d) {
                data[_d[p].name] = _d[p].value;
            }
            $.ajax({
                contentType:
                    "application/json",
                type:
                    'POST',
                url: url,
                data: JSON.stringify(data),
                success:
                    function (result) {
                        // $('.modal-dialog', window.top.document).parent('div').remove()
                        // $('body', window.top.document).find('.modal-backdrop').remove();
                        // jquery 调用刷新当前操作的table页面的refresh方法
                        // $(window.parent.document).contents().find(".tab-pane.fade.active.in iframe")[0].contentWindow.doQuery();
                        activeTabBodyRefresh();
                        if (result){
                            layer.msg('修改数据成功!', {icon: 1, time: 2000})
                            // window.Ewin.alert({message: '修改数据成功!'});
                        }
                        else{
                            window.Ewin.alert({message: '修改数据失败!'});
                        }
                    },
                error: function (status) {
                    window.Ewin.alert({message: status.status + ':修改数据失败!'});
                }
            });
            // }
        });
    })
    ]]>
</script>
<script th:src="@{/layer/layer.js}"></script>
</body>
</html>